
package wxk.interview.servlet;

import javax.servlet.*;
import java.io.IOException;

/**
 * @author wangxuekai
 * @version 2.2
 * @Date 2017/3/7.
 * @since 2.2
 */

public class MySimpleFilter implements Filter {
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("init filter...");
    }

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        // 必须有实现 这样全部的url使用MySimpleWithAnnotationServlet 的 service方法
        System.out.println("do filter invoked..");
        MySimpleWithAnnotationServlet servlet = new MySimpleWithAnnotationServlet();
        servlet.service(servletRequest, servletResponse);
    }

    public void destroy() {
        System.out.println("destroy method invoked...");
    }
}
